package com.xing.test;

import com.xlj.pojo.Address;
import com.xlj.pojo.User;
import com.xlj.service.userService;
import com.xlj.service.userServiceimp;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

public class testquery {
    @Test
    public void measurement(){
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        userService service = context.getBean("serviceimp", userService.class);
        List<User> allrole = service.getAllrole();
        for (User uu:allrole){
            System.out.println(uu);
        }
    }
    @Test
    public void test() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        userService service = context.getBean("serviceimp", userService.class);
        List<User> alls = service.getAlls();
        //List<User> all = service.getAll();
        for (User uu : alls) {
            System.out.println(uu);
        }
    }
    @Test
        public void measure () {
            ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        userService service = context.getBean("serviceimp", userService.class);
        List<User> all = service.getuaddress();
        User user = all.get(0);
        System.out.println(user);
        for (Address uu : user.getAddressList()) {
            System.out.println(uu);
        }
        }
    @Test
    public void measure1 () {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        userService service = context.getBean("serviceimp", userService.class);
      User user=new User();
      user.setUserName("ppjang");
      user.setPhone("123654");
      user.setAddress("大不列颠及悲哀尔王国");
        Integer user1 = service.addnewUser(user);
        System.out.println(user1);

    }
    @Test
    public void measureshiwu () {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        userService service = context.getBean("serviceimp", userService.class);
        User user=new User();
        user.setUserName("小帆帆");
        user.setPhone("123654");
        user.setAddress("悲哀尔王国");
        User user1=new User();
        user1.setUserName("BOBO");
        user1.setPhone("124");
        user1.setAddress("大不列颠");
        ArrayList<User> list = new ArrayList<>();
        list.add(user);
        list.add(user1);
        Integer integer = service.addNewUsers(list);
        System.out.println(integer);


    }
    }
